package com.tanhua.houtai.controller;

import com.tanhua.common.utils.NoAuthorization;
import com.tanhua.houtai.service.DynamicVerifiesService;
import com.tanhua.houtai.vo.PagerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("manage")
public class DynamicVerifiesController {
    @Autowired
    DynamicVerifiesService dynamicVerifiesService;
    @GetMapping("messages")
    @NoAuthorization
    public ResponseEntity<PagerVo> messageflipping( @RequestHeader("Authorization")String token,
                                                    @RequestParam(value="pagesize",defaultValue = "15",required = false)Integer pagesize,
                                                    @RequestParam(value = "page",defaultValue = "1",required = false)Integer page,
                                                    @RequestParam(value = "sortProp",required = false) String sortProp,
                                                    @RequestParam(value = "sortOrder",required = false) String sortOrder,
                                                    @RequestParam(value = "id", required = false)Integer publishId,
                                                    @RequestParam(value = "sd", required = false)String startDate,
                                                    @RequestParam(value = "ed", required = false)String endDate,
                                                    @RequestParam(value = "state" ,defaultValue = "3") String state){
        try {
          PagerVo pagerVo = dynamicVerifiesService.messageflipping(pagesize,page);
            if (pagerVo != null){
                return ResponseEntity.ok(pagerVo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

    }
}
